//
//  SEHospitalDetailInfoCell.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/6.
//

import UIKit

protocol SEHospitalDetailInfoCellDelegate: NSObjectProtocol {
    func hospitalDetailInfoCellZoomBtnAction(cell: SEHospitalDetailInfoCell)
}

class SEHospitalDetailInfoCell: UITableViewCell {

    static let className = "SEHospitalDetailInfoCell"
    static let reuseId = className

    weak var delegate: SEHospitalDetailInfoCellDelegate?

    @IBOutlet weak var hospitalNameLabel: UILabel!
    @IBOutlet weak var hospitalGradeLabel: UILabel! {
        didSet {
            hospitalGradeLabel.layer.cornerRadius = 3
            hospitalGradeLabel.layer.borderWidth = 1
            hospitalGradeLabel.layer.borderColor = UIColor.init(hex: "FFB32D").cgColor
            hospitalGradeLabel.layer.masksToBounds = true
        }
    }
    @IBOutlet weak var hospitalTypeLabel: UILabel! {
        didSet {
            hospitalTypeLabel.layer.cornerRadius = 3
            hospitalTypeLabel.layer.borderWidth = 1
            hospitalTypeLabel.layer.borderColor = UIColor.init(hex: "FFB32D").cgColor
            hospitalTypeLabel.layer.masksToBounds = true
        }
    }
    @IBOutlet weak var hospitalLogoImgView: UIImageView! {
        didSet {
            hospitalLogoImgView.layer.cornerRadius = 8
            hospitalLogoImgView.layer.masksToBounds = true
        }
    }
    @IBOutlet weak var hospitalAddressLabel: UILabel!
    @IBOutlet weak var hospitalDescribeLabel: UILabel!

    @IBAction func zoomBtbAction(_ sender: UIButton) {
        sender.isSelected = !sender.isSelected
        hospitalDescribeLabel.numberOfLines = sender.isSelected ? 0 : 1
        delegate?.hospitalDetailInfoCellZoomBtnAction(cell: self)
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    func updateData(_ viewModel: SEHospitalDetailViewModel) {
        hospitalLogoImgView.kf.setImage(urlString: viewModel.model.imgUrl)
        hospitalNameLabel.text = viewModel.model.name
        hospitalGradeLabel.text = " \(viewModel.model.hospitalJb) "
        hospitalTypeLabel.text = " \(viewModel.model.hospitalDb) "
        hospitalAddressLabel.text = viewModel.model.addr
        hospitalDescribeLabel.text = viewModel.model.introduction
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
